package com.personal.modules.sys.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.personal.common.bean.PageUtils;
import com.personal.common.bean.ResultMsg;
import com.personal.common.util.Query;
import com.personal.modules.sys.entity.TSysRoleMenuEntity;
import com.personal.modules.sys.service.TSysRoleMenuService;


/**
 * 角色与菜单对应关系
 * 
 * @author liuyuzhu
 * @email liuyuzhu.1314@gmail.com
 * @date 2017-10-09 16:34:03
 */
@RestController
@RequestMapping("tsysrolemenu")
public class TSysRoleMenuController {
	@Autowired
	private TSysRoleMenuService tSysRoleMenuService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("tsysrolemenu:list")
	public ResultMsg list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TSysRoleMenuEntity> tSysRoleMenuList = tSysRoleMenuService.queryList(query);
		int total = tSysRoleMenuService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(tSysRoleMenuList, total, query.getLimit(), query.getPage());
		
		return new ResultMsg(pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("tsysrolemenu:info")
	public ResultMsg info(@PathVariable("id") Long id){
		TSysRoleMenuEntity tSysRoleMenu = tSysRoleMenuService.queryObject(id);
		
		return new ResultMsg(tSysRoleMenu);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("tsysrolemenu:save")
	public ResultMsg save(@RequestBody TSysRoleMenuEntity tSysRoleMenu){
		tSysRoleMenuService.save(tSysRoleMenu);
		
		return new ResultMsg();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("tsysrolemenu:update")
	public ResultMsg update(@RequestBody TSysRoleMenuEntity tSysRoleMenu){
		tSysRoleMenuService.update(tSysRoleMenu);
		
		return new ResultMsg();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("tsysrolemenu:delete")
	public ResultMsg delete(@RequestBody Long[] ids){
		tSysRoleMenuService.deleteBatch(ids);
		
		return new ResultMsg();
	}
	
}
